//
//  EXT+UIImage.swift
//  Swift---新浪微博练习代码
//
//  Created by Mr.Yan on 2017/6/30.
//  Copyright © 2017年 Mr.Yan. All rights reserved.
//

import UIKit
//代码方式解决图片拉伸
extension UIImage{
//class修饰类方法
    class func resizableImage(named:String) ->UIImage{
    //图片
        let image = UIImage(named: named)!
        //设置端值
        let top = image.size.height * 0.5
        
        let left = image.size.width * 0.5

        let bottom = image.size.height * 0.5

        let right = image.size.width * 0.5

        let edgeInsets = UIEdgeInsetsMake(top, left, bottom, right)
        
        //拉伸图片
        let newImage = image.resizableImage(withCapInsets: edgeInsets)
        return newImage

        
    }
}
